package com.xuyiwei.xblog.core.base.constant.enums;

import com.xuyiwei.xblog.core.base.constant.ConstantStatusInterface;

import java.util.HashMap;
import java.util.Map;

/**
 * 数据库排序
 *
 * @author fengshuonan
 * @Date 2017年5月31日20:48:41
 */
public enum OrderEnum  implements ConstantStatusInterface<String,String> {

    NULL("",""),ASC("asc","升序"), DESC("desc","降序");


    private String key;
    private String desc;

    OrderEnum(String key, String desc) {
        this.key = key;
        this.desc = desc;
    }

    @Override
    public String getKey() {
        return key;
    }

    @Override
    public String getDesc() {
        return desc;
    }

    static Map<String, OrderEnum> map = new HashMap<>();

    static {
        for (OrderEnum bst : OrderEnum.values()) {
            map.put(bst.key, bst);
        }
    }

    public static OrderEnum convert(Integer key) {
        OrderEnum type = map.get(key);
        return (type != null) ? type : NULL;
    }

}
